using System;
using System.Collections.Generic;
using System.Net;
using System.Text;
using System.Web;

namespace BadWeb
{
    public class HttpVar
    {
        public string Key
        {
            get { return _key; }
            set
            {
                _key = value;
            }
        }

        public string Value
        {
            //get { return HttpUtility.UrlDecode(_value); }
            get { return _value; }
            //set { _value = HttpUtility.UrlEncode(value); }
            set { _value = value; }
        }

        public HttpVar()
        {

        }

        public static string GetVars(List<HttpVar> vars)
        {
            StringBuilder data = new StringBuilder();

            for (int n = 0; n < vars.Count; n++)
            {
                HttpVar thisVar = vars[n];

                if (data.Length == 0)
                {
                    data.Append(string.Format("{0}={1}", thisVar.Key, thisVar.Value));
                }
                else
                {
                    data.Append(string.Format("&{0}={1}", thisVar.Key, thisVar.Value));
                }
            }

            return data.ToString();
        }

        public HttpVar(string key, string value)
        {
            if (string.IsNullOrEmpty(key))
            {
                throw new ArgumentException("Must supply key.");
            }

            if (null == value)
            {
                throw new ArgumentException("Must supply value.");
            }

            _key = key;
            //_value = HttpUtility.UrlEncode(value);
            _value = value;
        }


        private string _key = string.Empty;

        private string _value = string.Empty;

        
    }
}
